package com.lhh.company.website.admin;

import com.lhh.company.website.entity.Res;
import com.lhh.company.website.entity.SysUser;
import com.lhh.company.website.service.SysUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class UserApi {

    @Resource
    SysUserService sysUserService;

    @RequestMapping ("/user/add")
    public Res<String> addSysUser(@RequestBody SysUser sysUser) {
        sysUserService.addSysUser(sysUser);
        return Res.succ("添加成功");
    }


    @RequestMapping ("/user/update")
    public Res<String> updateSysUser(SysUser sysUser) {
        sysUser.setPasswd(sysUser.getPasswd());
        sysUserService.updateById(sysUser);
        return Res.succ("更新成功");
    }


    @RequestMapping ("/user/delete")
    public Res<String> deleteSysUser(SysUser sysUser) {
        sysUser.setPasswd(sysUser.getPasswd());
        sysUserService.deleteSysUser(sysUser);
        return Res.succ("删除成功");
    }

}
